<html>
<head>
<title>Triple-arm crane</title>
</head>

<body>

<center>
<h1>POI VII Stage 2 Problem 3</h1>
<h1>Triple-arm crane</h1>
</center>

<p>
 A triple-arm crane places containers on railway wagons. The wagons are
 numbered in order 1, 2,...&nbsp;. On each wagon at most one container
 can be put. In one move the crane gets three containers from a storehouse
 and places them on wagons with numbers <i>i</i>, <i>i+p</i> and 
 <i>i+p+q</i>, or on wagons with numbers <i>i</i>, <i>i+q</i> and
 <i>i+p+q</i> (for some constants <i>p,q</i> &gt;= 1). 
 The crane has to be programmed in such way, that it loads with containers
 the first <i>n</i> wagons of the train (the train has <i>n+p+q</i>
 wagons). 
 The program consists of sequence of instructions. Each instruction
 describes one move of the crane. 

 Such instruction forms a <i>(x, y, z)</i> triple, where 
 1 &lt; <i>x < y < z</i> &lt; <i>n+p+q</i>, and determines numbers of
 wagons, on which the crane has to place the containers. 
 The program is <b>correct</b> if after its execution there is exactly one
 container on each of the first <i>n</i> wagons of the train.
</p>

<h2>Task</h2>
<p>
Write a program, which:
 <ul>
  <li>reads a description of the crane
   (numbers <i>p</i> and <i>q</i>) and a number of wagons to be loaded 
   (<i>n</i>) from the text file <tt>TRO.IN</tt> 
  <li>generates a correct program for the crane,
  <li>writes it to the text file <tt>TRO.OUT</tt>.
 </ul>
</p>      

<h2>Input</h2>
<p>
 The first and the only line of the text file <tt>TRO.IN</tt> contains
 exactly three positive integers separated by single spaces. These are
 adequately numbers <i>p</i> and <i>q</i> describing parameters of
 the crane and number <i>n</i>, being the number of the first wagons of
 the train to be loaded. These numbers satisfy inequalities 1 &lt;=
 <i>n</i> &lt;= 300000, 2 &lt;= <i>p+q</i> &lt;= 60000.
</p>

<h2>Output</h2>
<p>
 The first line of the text file <tt>TRO.OUT</tt> should consist of
 exactly one integer <i>m</i> being the number of instructions in
 the program generated. Each of the next <i>m</i> lines should consist of 
 exactly three integers <i>x</i>, <i>y</i>, <i>z</i> separated by single
 spaces, 1 &lt;= <i>x < y < z</i> &lt;= <i>n+p+q</i>, <i>x &lt;= n</i>,
 <i>y</i> belongs to {<i>x+p</i>, <i>x+q</i>}, <i>z = x+p+q</i>.
 These are the numbers of the wagons, on which the crane has to put
 containers in a consecutive move.
</p>

<h2>Sample Input</h2>
<pre>
2 3 10
</pre>

<h2>Sample Output</h2>
<pre>
4
1 3 6
2 4 7
5 8 10
9 11 14
</pre>

</body>

</html>
